<template>
    <el-header>
        <div class="left">
            <el-icon @click="handleCollasped">
                <Menu></Menu>
            </el-icon>
            <span style="margin-left: 10px;">企业门户管理系统</span>
        </div>
        <div class="right">
            <span style="margin-right: 18px;">欢迎 {{store.state.userInfo.username}} 回来</span>
            <el-dropdown>
                <span class="el-dropdown-link">
                    <el-icon :size="25" color="white">
                        <User></User>
                    </el-icon>
                </span>
                <template #dropdown>
                    <el-dropdown-menu>
                        <el-dropdown-item @click="handleCenter">个人中心</el-dropdown-item>
                        <el-dropdown-item @click="logout">退出登录</el-dropdown-item>
                    </el-dropdown-menu>
                </template>
            </el-dropdown>
        </div>

    </el-header>
</template>



<script setup>
import { Menu, User } from "@element-plus/icons-vue";
import { useStore } from 'vuex';
import { useRouter, useRoute } from "vue-router";
const store = useStore()
const route = useRoute()
const router = useRouter()
const handleCollasped = () => {
    store.commit('changeCollasped')
}
// 个人中心跳转
const handleCenter = () => {
    router.push('/center')
}
// 推出登录
const logout = () => {
    localStorage.removeItem('token')
    store.commit("clearUserInfo")
    router.push('/login')
}
</script>

<style lang="scss" scoped>
.el-header {
    background-image: url('@/assets/bg.jpg');
    background-repeat: no-repeat;
    background-size: cover;
    color: white;
    width: 100%;
    height: 60px;
    line-height: 60px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.left,
.right {
    display: flex;
}

.left {
    i {
        margin: auto;
    }
}

.right {
    .el-dropdown {
        margin: auto;
    }
}
</style>